package QC.MessageBox;

import QC.MessageBox.service.*;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;

/**
 * Created by Andaren on 2017/4/6.
 * Used for:
 */
public class BaseVerticle extends AbstractVerticle {
    protected DataAccess dataAccess;

    protected MySQLService mySQLService;

    protected RedisService redisService;

    protected HttpClient httpClient;

    protected WebClientService webClientService;

    protected HttpService httpService;

    protected BlockingService blockingService;

    @Override
    public void start() {

        // 初始化MySQL连接池、redis
        BaseJDBC.createSharedClient(vertx, config());

        // 创建http请求客户端
        HttpClientOptions httpClientOptions = new HttpClientOptions()
                .setConnectTimeout(5000) // 2000
                .setKeepAlive(false);
        httpClient = vertx.createHttpClient(httpClientOptions);

        // 初始化http服务
        httpService = new HttpService(httpClient);
        webClientService = new WebClientService(vertx);
        // 初始化服务
        mySQLService = new MySQLService(BaseJDBC.getSQLClient());
        redisService = new RedisService(BaseJDBC.getRedisClient());
//        mongoService = new MongoService(BaseJDBC.getMongoClient());
        dataAccess = new DataAccess(mySQLService, redisService);
        blockingService = new BlockingService(vertx);


    }

}
